package DFS;

import java.util.*;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-03-20
 * Time:18:16
 * Text：78. 子集
 */
public class Text6 {
    List<Integer> path;
    List<List<Integer>>  list2;
    boolean[] check;
    void dfs(int[] nums,int k){
        if(k==nums.length){
            List<Integer> path2=new ArrayList<>(path);
            list2.add(path2);
            return;
        }

        //不接收当下的值
        dfs(nums,k+1);

        //接收当下的值
        path.add(nums[k]);
        dfs(nums,k+1);
        path.remove(path.size()-1);
    }
    public List<List<Integer>> subsets(int[] nums) {
        path=new ArrayList<>();
        list2=new ArrayList<>();
        check=new boolean[nums.length];
        dfs(nums,0);
        return list2;
    }
    public static void main(String[] args) {
        Text6 t1=new Text6();
        int[] array={1,2,3};
        t1.subsets(array);
    }
}
